package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Frame;
import java.util.Vector;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import person.PersonAchive;

public class ScenarioDialog extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JTabbedPane ScenarioTabs = null;
	public static boolean[] compiled;

	/**
	 * @param owner
	 */
	public ScenarioDialog(Frame owner) {
		super(owner);
		initialize();
		scenarios = new Vector<String>();
		addPanes();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(560, 420);
		this.setContentPane(getJContentPane());
	}

	private void addPanes() {
		for (int i = 0; i < PersonAchive.getCount(); i++) {
			ScenarioTabs.addTab(PersonAchive.getPerson(i).getName(),
					buildPanel(i));
		}
		ScenarioTabs.addTab("Weather", buildPanel(PersonAchive.getCount()));
		compiled = new boolean[PersonAchive.getCount() + 1];
	}

	private PanelModel buildPanel(int index) {

		return new PanelModel(index);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setBackground(new Color(250, 250, 250));
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getScenarioTabs(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes ScenarioTabs
	 * 
	 * @return javax.swing.JTabbedPane
	 */
	private JTabbedPane getScenarioTabs() {
		if (ScenarioTabs == null) {
			ScenarioTabs = new JTabbedPane();
			ScenarioTabs.setBackground(new Color(250, 250, 250));
		}
		return ScenarioTabs;
	}

	public static void main(String args[]) {
		new ScenarioDialog(new JFrame()).setVisible(true);
	}

	public static Vector<String> scenarios = new Vector<String>(); // @jve:decl-index=0:

	public Vector<String> getScenarios() {
		return scenarios;
	}

	public static boolean allCompiled() {
		boolean res = true;
		for (int i = 0; i < compiled.length; i++)
			res = res & compiled[i];
		return res;
	}

} // @jve:decl-index=0:visual-constraint="10,10"
